<template>
  <view class="profile-page">
    <!-- 用户信息头部 -->
	
    <view class="page-header">
    	<view class="status-bar"></view>
    	<view class="header-title">新阳光广场</view>
    	<view class="header-content">
    		<view class="user-info">
    			<view class="avatar-section">
    				<view class="avatar">
    					<text class="avatar-text">{{ $userInfo.nickName.charAt(0) }}</text>
    				</view>
    			</view>
    			<view class="user-details">
    				<text class="username">{{ $userInfo.nickName }} </text>
    				<text class="role">{{ getUserRole() }}</text>
    				<!-- <view class="online-status"
    								v-if="$userInfo.role != 4 && $userInfo.role !=5 && $userInfo.role !=1">
    								<uni-tag size="mini" :text="$userInfo.isOnline ? '在岗' : '离岗'"
    									:type="$userInfo.isOnline?'success':'error'" :circle="true"></uni-tag>
    							</view> -->
    			</view>
    		</view>
    		<!-- <view class="stats" v-if="$userInfo.role == 3">
    			<view class="stat-item">
    				<text class="stat-value">{{ todyTotal }}</text>
    				<text class="stat-label">今日接待</text>
    			</view>
    		</view>
    		<view class="stats" v-if="$userInfo.role == 6 || $userInfo == 7">
    			<view class="stat-item">
    				<text class="stat-value">{{ totalRe }}</text>
    				<text class="stat-label">今日认购</text>
    			</view>
    			<view class="stat-item">
    				<text class="stat-value">{{ totalPrice }}</text>
    				<text class="stat-label">今日销售</text>
    			</view>
    		</view> -->
    	</view>
    </view>

    <!-- 业绩统计 -->
    <!-- <view class="stats-section">
      <view class="stats-grid">
        <view class="stat-card">
          <text class="stat-value">{{ performance.monthSales }}</text>
          <text class="stat-label">本月成交</text>
        </view>
        <view class="stat-card">
          <text class="stat-value">{{ performance.totalSales }}</text>
          <text class="stat-label">累计成交</text>
        </view>
        <view class="stat-card">
          <text class="stat-value">{{ performance.successRate }}%</text>
          <text class="stat-label">成交率</text>
        </view>
        <view class="stat-card">
          <text class="stat-value">¥{{ performance.commission }}万</text>
          <text class="stat-label">本月佣金</text>
        </view>
      </view>
    </view> -->
    <!-- 功能菜单 -->
    <view class="menu-section quick-actions">
      <!-- <view class="menu-title">个人功能</view> -->
      <view class="menu-list">
        <!-- <view class="menu-item" @click="navigateTo('myCustomers')">
          <view class="menu-icon">
			  
			  <uni-icons type="auth" size="30"></uni-icons>
			  </view>
          <text class="menu-text">我的客户</text>
          <text class="menu-arrow">›</text>
        </view> -->
       <!-- <view class="menu-item" @click="navigateTo('performance')">
          <view class="menu-icon"></view>
          <text class="menu-text">业绩统计</text>
          <text class="menu-arrow">›</text>
        </view> -->
		<view class="menu-item" @click="navigateTo('house')" >
		  <view class="menu-icon">
			<image src="@/static/imgs/build.png"></image>
		  </view>
		  <text class="menu-text">房源</text>
		  <text class="menu-arrow">›</text>
		</view>
		<view class="menu-item" @click="navigateTo('manager')" >
		  <view class="menu-icon">
			<!-- <uni-icons type="personadd-filled" size="30"></uni-icons> -->
			<image src="@/static/imgs/customer-ac.png"></image>  
		  </view>
		  <text class="menu-text">我的团队</text>
		  <text class="menu-arrow">›</text>
		</view>
		<view class="menu-item" @click="handleLogout">
		  <view class="menu-icon">
			  <image src="@/static/imgs/loginOut.png"></image>  
		  </view>
		  <text class="menu-text">退出登录</text>
		  <text class="menu-arrow">›</text>
		</view>
        <!-- <view class="menu-item" @click="navigateTo('schedule')">
          <view class="menu-icon"></view>
          <text class="menu-text">我的日程</text>
          <text class="menu-arrow">›</text>
        </view>
        <view class="menu-item" @click="navigateTo('settings')">
          <view class="menu-icon">⚙️</view>
          <text class="menu-text">系统设置</text>
          <text class="menu-arrow">›</text>
        </view> -->
		
		<view class="menu-item" @click="navigateTo('sign')">
		  <view class="menu-icon"></view>
		  <text class="menu-text">测试电话号码</text>
		  <text class="menu-arrow">›</text>
		</view>
      </view>
    </view>

    <!--  
    <view class="menu-section">
      <view class="menu-title">系统功能</view>
      <view class="menu-list">
        <view class="menu-item" @click="navigateTo('help')">
          <view class="menu-icon">❓</view>
          <text class="menu-text">帮助中心</text>
          <text class="menu-arrow">›</text>
        </view>
        <view class="menu-item" @click="navigateTo('feedback')">
          <view class="menu-icon"></view>
          <text class="menu-text">意见反馈</text>
          <text class="menu-arrow">›</text>
        </view>
        <view class="menu-item" @click="navigateTo('about')">
          <view class="menu-icon">ℹ️</view>
          <text class="menu-text">关于我们</text>
          <text class="menu-arrow">›</text>
        </view>
        <view class="menu-item logout" @click="handleLogout">
          <view class="menu-icon"></view>
          <text class="menu-text">退出登录</text>
          <text class="menu-arrow">›</text>
        </view>
      </view>
    </view> -->
  </view>
</template>

<script>
export default {
  data() {
    return {
      userInfo: {
        name: '张销售',
        role: '高级销售顾问',
        employeeId: 'S0088',
        avatar: '/static/avatars/sales-avatar.jpg',
        department: '销售部',
        joinDate: '2023-03-15'
      },
      performance: {
        monthSales: 12,
        totalSales: 89,
        successRate: 68,
        commission: 5.6,
        ranking: 3
      }
    }
  },
  
  methods: {
    navigateTo(page) {
      const routes = {
        myCustomers: '/pages/customer/my',
        performance: '/pages/performance/index',
        manager: '/pages/profile/manager',
        settings: '/pages/settings/index',
        help: '/pages/help/index',
        feedback: '/pages/feedback/index',
        about: '/pages/about/index',
		house:'/pages/properties/index',
		sign:"/pages/customer/sign"
      }
      
      if (routes[page]) {
        uni.navigateTo({
          url: routes[page]
        })
      }
    },
    getUserRole() {
    	let appUser = this.$userInfo
    	let role = appUser.role
    	let res = ''
    	switch (role) {
    		case 3:
    			res = '高级置业顾问'
    			break;
    		case 4:
    		case 5:
    			res = appUser.agency
    			break;
			case 7:
				res = '销售经理'
				break;
			case 8:
				res = '营销经理'
				break;
    		default:
    			break;
    	}
    
    	console.log(role)
    	return res
    },
    handleLogout() {
      uni.showModal({
        title: '确认退出',
        content: '确定要退出登录吗？',
        success: (res) => {
          if (res.confirm) {
            // 清除登录状态
            uni.removeStorageSync('userInfo')
            
            // 跳转到登录页
            uni.reLaunch({
              url: '/pages/login/login'
            })
          }
        }
      })
    }
  }
}
</script>

<style scoped lang="scss">
.profile-page {
  min-height: 100vh;
  background: #f5f6fa;
  padding-bottom: 40rpx;
}




.user-id {
  font-size: 22rpx;
  opacity: 0.8;
}

.stats-section {
  padding: 30rpx 20rpx;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20rpx;
}

.stat-card {
  background: white;
  border-radius: 16rpx;
  padding: 30rpx;
  text-align: center;
  box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
}

.stat-value {
  font-size: 36rpx;
  font-weight: bold;
  color: #667eea;
  display: block;
  margin-bottom: 8rpx;
}

.stat-label {
  font-size: 24rpx;
  color: #666;
}


.menu-title {
  font-size: 28rpx;
  font-weight: bold;
  color: #333;
  margin-bottom: 20rpx;
  padding-left: 10rpx;
}

.menu-list {
  background: white;
  border-radius: 16rpx;
  overflow: hidden;
  box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 30rpx;
  border-bottom: 1rpx solid #f1f2f6;
  
  &:last-child {
    border-bottom: none;
  }
  
  &.logout {
    .menu-icon, .menu-text, .menu-arrow {
      color: #ff4757;
    }
  }
}

.menu-icon {
  font-size: 36rpx;
  margin-right: 24rpx;
  width: 40rpx;
  text-align: center;
  image {
	  width: 40rpx;
	  height: 40rpx;
  }
}

.menu-text {
  flex: 1;
  font-size: 28rpx;
  color: #333;
}

.menu-arrow {
  font-size: 32rpx;
  color: #999;
  font-weight: bold;
}
</style>